<?php
$baseURL = './CentralController.php?surveycode=Surveys'; 
require_once ROOT_PATH . '/lib/extractor/surveys/EXTRACTOR_surveys.php';
 ?>
 <script type="text/javascript">
 function returnAdd() {
		location.href = '<?php echo $baseURL;?>&action=ViewAddQuestion';
}
function returnDelete() {
		var check = false;
		with (document.frmQuestion) {
			for (var i=0; i < elements.length; i++) {
				if ((elements[i].type == 'checkbox') && (elements[i].checked == true)){
					check = true;
					break;
				}
			}

			if (check) {
				document.frmQuestion.action= "<?php echo $_SERVER['PHP_SELF']; ?>?surveycode=Surveys&action=DeleteQuestions";
				document.frmQuestion.submit();
			} else {
				alert("<?php echo $lang_Error_SelectAtLeastOneRecordToDelete; ?>");
			}
		}
	}
 </script>
<h2><?php echo $lang_Questions_List; ?><hr/></h2>
<form id="frmQuestion" name="frmQuestion" method="post" action="">
<div style="padding: 6px;">
				<img 
					title="Add" 
					alt="Add"
					src="../../themes/beyondT/pictures/btn_add.gif" 
					style="border: none;"
					onclick="returnAdd();"
					onmouseout="this.src='../../themes/beyondT/pictures/btn_add.gif';" 
					onmouseover="this.src='../../themes/beyondT/pictures/btn_add_02.gif';" />	
					 
					<img 
						title="Delete" 
						alt="Delete" 
						src="../../themes/beyondT/pictures/btn_delete.gif" 
						style="border: none;"
						onclick="returnDelete();"
						onmouseout="this.src='../../themes/beyondT/pictures/btn_delete.gif';"
						onmouseover="this.src='../../themes/beyondT/pictures/btn_delete_02.gif';" />
					
</div>
<table border="0" cellpadding="0" cellspacing="0">
  <thead>
  	<tr>
		<th class="tableTopLeft"></th>
		<th class="tableTopMiddle" ></th>
    	<th class="tableTopMiddle" width="500" ></th>
    	<th class="tableTopMiddle"></th>
		<th class="tableTopRight"></th>
	</tr>
	<tr>
		<th class="tableMiddleLeft"></th>
		<th class="tableMiddleMiddle"></th>
    	<th class="tableMiddleMiddle"><?php echo $lang_Question_Text; ?></th>
    	<th  class="tableMiddleMiddle"><?php echo $lang_Question_Surveys; ?></th>    	
		<th class="tableMiddleRight"></th>
	</tr>
  </thead>
  <tbody>
<?php
	$j = 0;
	if (is_array($records)) {		
		foreach ($records as $record) {
			$survey = Surveys::getSurvey($record->getSurveyId()); 
			//$surveyOwner = 
			if(!($j%2)) {
				$cssClass = 'odd';
			 } else {
			 	$cssClass = 'even';
			 }
			 $j++;

?>
  <tr>
  	<td class="tableMiddleLeft"></td>
  	<td class="<?php echo $cssClass?>" align="center"> <input type='checkbox' class='checkbox' name='chkID[]' value='<?php echo $record->getId();?>'></td>
    <td class="<?php echo $cssClass; ?>"><a href="CentralController.php?surveycode=Surveys&action=ShowEditQuestion&id=<?php echo $record->getId(); ?>" target="rightMenu"><?php echo $record->getText(); ?></a></td>
    <td class="<?php echo $cssClass; ?>"><?php echo $survey->getSurveyName(); ?></td>
	<td class="tableMiddleRight"></td>
  </tr>

<?php
		}
	}
?>
  </tbody>
  <tfoot>
  	<tr>
		<td class="tableBottomLeft"></td>
		<td class="tableBottomMiddle"></td>					
		<td class="tableBottomMiddle"></td>
		<td class="tableBottomMiddle"></td>
		<td class="tableBottomRight"></td>
	</tr>
  </tfoot>
</table>

